<template>
  <div>
    <h2><slot></slot></h2>

    <p>{{ mySquareOfCounter }}</p>
    <p>{{ squareOfCounter }}</p>
    <p>{{ squareOfCounter2 }}</p>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'Getters2',
  computed: {
    // getters → 组件的 computed
    mySquareOfCounter() {
      return this.$store.getters.squareOfCounter
    },

    // mapGetters
    ...mapGetters(['squareOfCounter']),

    // mapGetters 重命名
    ...mapGetters({
      squareOfCounter2: 'squareOfCounter'
    })
  }
}
</script>
